package dao;

import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import pojo.Blog;

import java.util.List;
import java.util.Map;

public class BlogMapperImpl2 extends SqlSessionDaoSupport implements BlogMapper {

    public List<Blog> queryBlogIf(Map map) {
//        SqlSession sqlSession = getSqlSession();
//        BlogMapper mapper = sqlSession.getMapper(BlogMapper.class);
//        return mapper.queryBlogIf(map);
//        等价于
        return getSqlSession().getMapper(BlogMapper.class).queryBlogIf(map);
    }


    public List<Blog> queryBlogChoose(Map map) {

        BlogMapper mapper = getSqlSession().getMapper(BlogMapper.class);
        mapper.updateBlog(map);
        mapper.queryBlogIf(map);
        return mapper.queryBlogChoose(map);
    }

    public int updateBlog(Map map) {
        return  getSqlSession().getMapper(BlogMapper.class).updateBlog(map);
    }

    public List<Blog> queryBlogForeach(Map map) {
        return getSqlSession().getMapper(BlogMapper.class).queryBlogForeach(map);
    }
}
